<template>
  <basic-container>
    <avue-crud v-if="tableOption"
               v-bind="bindVal"
               v-on="onEvent"
               v-model:page="page"
               v-model="startForm">
      <template #menu-btn="{size,type,row,index}">
        <el-dropdown-item icon="el-icon-edit-pen" :size="size"
                          @click.native="$refs.actModelDesign.show(row.id, '修改流程【' + row.modelName + '】') "
                          :type="type">设计模型
        </el-dropdown-item>

        <el-dropdown-item icon="el-icon-promotion" :size="size" @click.native="deploymentModel(row)"
                          :type="type">部署流程
        </el-dropdown-item>
        <el-dropdown-item icon="el-icon-search" :size="size" @click.native="openDeploymentHistory(row)"
                          :type="type">部署历史
        </el-dropdown-item>
        <!--        <el-button text-->
        <!--                   type="primary"-->
        <!--                   @click="deploymentModel(row)"-->
        <!--                   icon="el-icon-circle-plus-outline"-->
        <!--        >-->
        <!--        </el-button>-->
        <!--        <el-button text-->
        <!--                   type="primary"-->
        <!--                   @click="openDeploymentHistory(row)"-->
        <!--                   icon="el-icon-search"-->
        <!--        >部署历史-->
        <!--        </el-button>-->

      </template>
    </avue-crud>
    <act-model-design ref="actModelDesign" @submit="refreshChange"></act-model-design>

  </basic-container>
</template>

<script>
import actModelApi from "@/api/start/activiti/actModelApi";
import {createDynamicMixin} from "@/mixins/startCrud";
import ActModelDesign from "./actModelDesign.vue";
import autoRouter from "@/views/start/activiti/autoRouter";
import EditModelFormPropDialog from "@/views/start/activiti/model/editModelFormPropDialog.vue";

export default {
  computed: {},
  mixins: [createDynamicMixin({
    name: "start/activiti/actModel"
  })],
  components: {EditModelFormPropDialog, ActModelDesign},

  methods: {

    openDeploymentHistory(row) {
      let config = {};
      config.name = autoRouter.names.procModelDeploymentHistory
      config.params = {}
      config.params.modelKey = row.modelKey
      config.params.modelName = row.modelName
      console.log("config", config)
      this.$router.push(config)
    },
    loadCrudOptionAfter(option) {
    },
    afterRowSave(row, res) {
      let data = res.data.data
      this.$confirm("是否立即配置流程【" + data.modelName + "】", "系统提示").then(res => {
        this.$refs.actModelDesign.show(data.id, "修改流程【" + data.modelName + "】")
      }).catch(() => {

      })
    },


    deploymentModel(row) {
      this.$confirm(`您确定要部署【${row.modelName}】流程吗？ 是否继续?`, '系统提示', {
        confirmButtonText: '是',
        cancelButtonText: '否',
        type: 'warning'
      }).then(() => {
        return actModelApi.deploymentModel(row.id).then(res => {
        }).then(res => {
          this.$message.success(`【${row.modelName}】的流程部署成功`)
          this.refreshChange();
        })
      })


    }
  },

}


</script>


<style scoped>

</style>
